﻿package {
	
	import flash.display.*;
	import flash.events.*;
	
	import lt.uza.utils.*;

	public class Volk extends MovieClip {
		//VARS
		
		private var global:Global = Global.getInstance();
		
		var vector: Array =[0,0];
		var destination: Array =[0,0];
		var ID:int;
		var IDparent:int;
		var placeholder: Sprite= new Sprite();

		public function Volk():void{
			//INIT
			
			
			//Show GFX
			placeholder.graphics.beginFill(33<<16 | 33<<8 | 33);
			placeholder.graphics.drawCircle(0, 0, 5);
			this.addChild(placeholder);
		}
		
		private function Move():void{
			x+=vector[0];
			y+=vector[1];
			
		}
		
		public function Goto(xx:int,yy:int):void{
			
			destination[0] = xx ;
			destination[1] = yy ;
			UpdateVector();
			
		}
		
		public function UpdateVector():void{
			var a = destination[0]-x;
			var b = destination[1]-y;
			var len=Math.sqrt(a*a+b*b);			
			vector[0]=a/len;
			vector[1]=b/len;
		}
		
		public function Update():void{
			x+= global.camera._x;
			y+= global.camera._y;
			
			destination[0]+= global.camera._x;
			destination[1]+= global.camera._y;
			
			
			if((Math.abs(destination[0]-x)>=10 || Math.abs(destination[1]-y)>=10)){
				Move();

			}
			
		}
				
	}
}